/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.se2.meteocal.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import static javax.persistence.TemporalType.DATE;

/**
 *
 * @author Ugo
 */

@Entity
@NamedQueries({
    @NamedQuery(name = Weather.findByLocationAndDate, query = "SELECT w FROM Weather w WHERE w.location=:location AND w.date=:date"),  
    @NamedQuery(name = Weather.findByLocation, query = "SELECT w FROM Weather w WHERE w.location=:location ORDER BY w.date ASC"),  
    @NamedQuery(name = Weather.deleteAll, query = "DELETE FROM Weather"),  

})
public class Weather implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String findByLocationAndDate = "Weather.findByLocationAndDate";
    public static final String findByLocation = "Weather.findByLocation";
    public static final String deleteAll = "Weather.deleteAll";

   
    
    public Weather(){
        this.date=null;
        this.location=null;
        this.tempmax="Unknown";
        this.tempmin="Unknown";
        this.humidity="Unknown";
        this.rain="Unknown";
        this.windspeed="Unknown";
        this.maincond="Unknown";
        this.description="Unknown";
        this.icon="NA";
    }
    
    //@GeneratedValue(strategy = GenerationType.AUTO)
    //@Id 
   // private Long id;
    
   
    
    @Temporal(DATE)
    @Column(name="DATE")
    @Id
    private Date date;
    
    
    @OneToOne
    @Id
    private Location location;
    
    private String tempmin;
    
    private String tempmax;
    
    private String humidity;
    
    private String rain;
    
    private String windspeed;
    
    private String maincond;
    
    private String description;
    
    private String icon;
    
    
    public String getTempmin(){
        return this.tempmin;
    }  
    
    public void setTempmin(String tempmin){
        this.tempmin=tempmin;
    }
   
    public String getTempmax(){
        return this.tempmax;
    }  
    
    public void setTempmax(String tempmax){
        this.tempmax=tempmax;
    }
    
    public String getHumidity(){
        return this.humidity;
    }  
    
    public void setHumidity(String humidity){
        this.humidity=humidity;
    }
    
    public String getRain(){
        return this.rain;
    }  
    
    public void setRain(String rain){
        this.rain=rain;
    }
    
    public String getWindspeed(){
        return this.windspeed;
    }  
    
    public void setWindspeed(String windspeed){
        this.windspeed=windspeed;
    }
    
    public String getMaincond(){
        return this.maincond;
    }  
    
    public void setMaincond(String maincond){
        this.maincond=maincond;
    }
    
    public String getDescription(){
        return this.description;
    }  
    
    public void setDescription(String description){
        this.description=description;
    }
    
    public Date getDate(){
        return this.date;
    }
    
    public void setDate(Date date){
        this.date=date;
    } 
    
    public Location getlocation(){
        return this.location;
    }
    
    public void setLocation(Location location){
        this.location=location;
    }
    
    public String getIcon(){
        return this.icon;
    }
    
    public void setIcon(String icon){
        this.icon=icon;
    }
    
    /*public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }*/

  
    
}
